﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class ListCourseForm : Form
    {

        public string IDEmp { set; get; }
        public string NameEmp { set; get; }

        public ListCourseForm()
        {
            InitializeComponent();
        }

        SynchronizeData sync = new SynchronizeData();

        private void ListCourseForm_Load(object sender, EventArgs e)
        {
            ////Load du lieu can update
            //sync.GetDataForUpdateMethodWithID(sync.CourTb, sync.updatecol);

            CourseDataProvider load = new CourseDataProvider();
            DataSet ds = load.loadCourses();
            DataTable dt = ds.Tables[0];
            GridListCourse.DataSource = dt;
        }

        private void btnChange_Click(object sender, EventArgs e)
        {
            if (GridListCourse.SelectedCells.Count > 0)
            {
                ChangeCourseForm changeCourse = new ChangeCourseForm();
                changeCourse.IdCourse = GridListCourse.CurrentRow.Cells["ID"].Value.ToString();
                changeCourse.NameCoure = GridListCourse.CurrentRow.Cells["NameCourse"].Value.ToString();
                changeCourse.Startday = GridListCourse.CurrentRow.Cells["StartDate"].Value.ToString();
                changeCourse.AcceptRegis = GridListCourse.CurrentRow.Cells["AcceptReigister"].Value.ToString();
                changeCourse.NoteCour = GridListCourse.CurrentRow.Cells["Note"].Value.ToString();
                changeCourse.IDEmp = IDEmp;
                changeCourse.NameEmp = NameEmp;
                changeCourse.Show();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {

            ////Load du lieu can update
            //sync.GetDataForUpdateMethodWithID(sync.CourTb, sync.updatecol);

            CourseDataProvider load = new CourseDataProvider();
            DataSet ds = load.loadCourses();
            DataTable dt = ds.Tables[0];
            GridListCourse.DataSource = dt;
        }
    }
}
